package com.xnyzc.lhy.common.penum.vehicle;

import com.xnyzc.lhy.common.entity.PEnum;

/**
 * @Author: huxuekuo
 * @Date: 2019-07-26 13:46
 * @Description: 定义车辆类型
 */
public enum EvehicleType implements PEnum<String> {

    economic(0, "经济型"),
    comfortable(1, "舒适型"),
    business(2, "商务型"),
    luxury(3, "豪华型"),
    other(4, "其他");

    private String value;
    private int type;

    /**
     * 新增toShowString方法用于获取中文显示内容
     *
     * @return
     */
    @Override
    public String toChString() {
        return null;
    }

    EvehicleType(int type, String value) {
        this.type = type;
        this.value = value;
    }

    public static EvehicleType findById(Integer type) {
        EvehicleType evehicleType;
        switch (type) {
            case 0:
                evehicleType = EvehicleType.economic;
                break;
            case 1:
                evehicleType = EvehicleType.comfortable;
                break;
            case 2:
                evehicleType = EvehicleType.business;
                break;
            case 3:
                evehicleType = EvehicleType.luxury;
                break;
            case 4:
                evehicleType = EvehicleType.other;
                break;
            default:
                throw new IllegalArgumentException("非法type");
        }
        return evehicleType;
    }

    @Override
    public String getValue() {
        return this.value;
    }

    public int getType() {
        return this.type;
    }
}
